package com.yuanlai.quartz.listenner;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.stereotype.Component;

import com.yuanlai.quartz.model.domain.TaskDo;
import com.yuanlai.quartz.model.vo.TaskVo;
import com.yuanlai.quartz.service.ITaskService;

/**
 * 项目启动后 加载数据库中的任务数据
 * @author yuanlai
 *
 */
@Component
public class ScheduleJobInitListener  implements CommandLineRunner {
	
	@Autowired
	private ITaskService taskService;

	@Override
	public void run(String... args) throws Exception {
		// 从数据库表中拿到
		List<TaskVo> allTaskList = taskService.selectAllTask();
		//开始初始化
		taskService.initWhenStart(allTaskList);
	}

	

}
